
import React from 'react'
import { connect } from 'dva'
import { Form, Button, Modal, Row, Col, Input, Select, Cascader, Icon, Checkbox, Tabs,  DatePicker,message } from 'antd'
import config from 'config/config'
import { mapStateToProps } from 'utils/view_utils'
import styles from './codeChannelEditStyle.less'
import classnames from 'classnames/bind';
let cx = classnames.bind(styles);
import Uploader from 'widget/Upload'
import Ueditor from 'widget/Editor/Ueditor.js'
import moment from 'moment';
import { isEmpty, isArray, cloneDeep, set, get, pick } from 'lodash'
import { CollapsiblePanels } from 'widget/CollapsiblePanels/index'
// 引入列表页组件
import ListPage from 'widget/PageTmpl/ListPage'
const { TextArea } = Input;
const objhref = {
    1:'楼盘主页',
    2:'秒杀竞拍',
    3:'外部链接',
    4:'美的置业云小程序首页',
    5:'自定义页面',
}


//(1:推介 2：内部链接 3：资讯 4:外部链接 5：活动，6：预约看房，7：美房详情)
const FormItem = Form.Item
const {RangePicker}=DatePicker
const TabPane = Tabs.TabPane
const confirm = Modal.confirm;
const advertisingWindowDetailView = function ({ dispatch, model, form }) {
    const { resetFields, getFieldDecorator, validateFields, setFieldsValue } = form
    const { modelObj, namespace } = model
    let { query2,query1, city, actionType,  hrefModalObj,  biz, currentItem,areaList1,  value,regions,products,types,scan,productName ,list,showUl,roleType,show,location,showAll} = modelObj
    const formItemLayout = {
        labelCol: { span: 2 },
        wrapperCol: { span: 8 },
    };
   
    const formItemLayout1 = {
        labelCol: { span: 2 },
        wrapperCol: { span: 20 },
    };
    const formItemLayoutPro = {
        labelCol: { span: 8 },
        wrapperCol: { span: 14 },
    };
    const formItemLayout2 = {
        labelCol: { span: 4 },
        wrapperCol: { span: 20 },
    };
    const changeState = (payload) => {
      console.log(payload.hrefModalObj.jumpLocation,payload.hrefModalObj.busiName)
      if(payload.hrefModalObj.jumpLocation==1 && payload.hrefModalObj.busiName=='undefined'){
        console.log(333)
        payload.hrefModalObj.jumpUrl= "pages/biz/buildingDetail/buildingDetail?productId="+payload.currentItem[0]
        payload.hrefModalObj.busiName=query2.productName
        payload.hrefModalObj.params.busiId=query2.productId
        console.log(query2.productId)
      }
        dispatch({
          type: `${namespace}/updateStore`,
          payload: {...payload,location,hrefModalObj}
        })
        
      }
    function updateModal (flag = false, obj = {}) {
        let visible = flag
        hrefModalObj.visible = flag
        if (!visible) { //关闭
          changeState({hrefModalObj,})
          return false
        }
         form.resetFields(['new_href'])
         form.resetFields(['jumpLocation'])
        changeState({hrefModalObj})
      }

      //秒杀竞拍mock数据
 function getTopicList () { //1美的置业云 2智美分销
    let rows= [
      
      {
        'id': '1',
        'title': '秒杀',
        'jumpUrl': 'pages/biz/kill/killHome/killHome',
      },
      {
        'id': '2',
        'title': '竞拍',
        'jumpUrl': 'pages/biz/auctions/auction/auction',
      },
    ]
    
    // if(channelIndex=='2'){
    //   rows=cloneDeep([rows[0]])
    // }
    let toppicList = {
      // "pageNo": 1,
      'pageSize': 10,
      'rows': cloneDeep(rows),
      'success': true,
      // "total": 150
    }
    return toppicList
  }
      function getHref (params) {
        console.log(params,'params')
        let hrefMap = {
          1: {//楼盘
            jumpLocation: '1',
            hrefTypeName: '楼盘主页',
            jumpUrl: `pages/biz/buildingDetail/buildingDetail?productId=${params.productId}`,
            busiName: `${params.name}`,
            query2: 'productId',
            params: {busiId: params.productId}
          },
          2: {  //秒杀竞拍
            jumpLocation: '2',
            hrefTypeName: '秒杀竞拍',
            jumpUrl: `${params.type==1?'pages/biz/kill/killHome/killHome':'pages/biz/auctions/auction/auction'}`,
            busiName: `${params.name}`,
            query2: 'seckillActivityId',
            params: {busiId: params.seckillActivityId}
          },
        //   3: {  //资讯
        //     jumpLocation: '3',
        //     hrefTypeName: '资讯',
        //     href: `pages/biz/InformationDetail/InformationDetail?id=${params.contentId}`,
        //     title: `${params.title}`,
        //     query: 'id',
        //     params: {key: params.contentId}
        //   },
          3: {   //外部链接
            // jumpLocation: '4',
            // hrefTypeName: '外部链接',
            // jumpUrl: `${params.jumpUrl}`,
            // title: '轮播图',
            // query: '',
            // 
            jumpLocation: '3',
            hrefTypeName: '外部链接',
            btnName:params.name || params.btnName,
            jumpUrl:params.jumpUrl || '',
            params: {key: params.jumpUrl},
          },
          4:{
            jumpLocation: '4',
            hrefTypeName: '美的置业云小程序首页',
          },
          5:{
            jumpLocation: '5',
            hrefTypeName: '自定义',
          }
        //   5: {   //活动
        //     hrefType: '5',
        //     hrefTypeName: '活动',
        //     // href: `pages/biz/findHouse/activity/apply/apply?contentId=${params.contentId}&productId=${params.productId}`,
        //     href: `pages/biz/findHouse/activity/apply/apply?contentId=${params.contentId}&productId=${params.businessId}`,
        //     title: `${params.title}`,
        //     query: 'contentId',
        //     params: {key: params.contentId}
        //   },
        }
        
        let item = hrefMap[params.jumpLocation] || {}
        return item
      }
        function changeTab_modal (jumpLocation) {
            hrefModalObj.jumpLocation = jumpLocation
            if(hrefModalObj.jumpLocation!='3'){
              
            }
            changeState({biz,hrefModalObj})
        }
        const confirmHref = () => {
            let hrefInfo = {}
            let {visible = false, jumpLocation = '3', idx = 0, slideshowId = ''} = hrefModalObj
            hrefModalObj.visible = !visible
            // query2.linkType = hrefModalObj.jumpLocation              
            // debugger
            // 判断类型，整合数据
            
              location=jumpLocation
            if (jumpLocation == '3') {
              if (!hrefModalObj.jumpUrl || !hrefModalObj.jumpUrl.trim()) {
                  message.warn('请输入链接')
                  return false
              }
              // hrefModalObj.jumpUrl = hrefModalObj.outerlinkUrl
              hrefModalObj.busiName = "",
              hrefInfo = getHref(cloneDeep(hrefModalObj))
            }else if(jumpLocation == '5'){
              if(!query2.title||query2.title==""){
                message.warn('请输入自定义标题')
                return false
              }
              if(!query2.content||query2.content==""){
                message.warn('请输入自定义内容')
                return false
              }
              hrefModalObj.busiName = "",
              hrefModalObj.linkUrl = ''
              hrefModalObj.jumpUrl= 'subPackages/pages/toPage/toPage'
            }else{
              let selectedRows = (biz[jumpLocation] || {})['selectedRows'] || {}
              let selectedRowKeys = (biz[jumpLocation] || {})['selectedRowKeys'] || {}
              if (isEmpty(selectedRowKeys)&&jumpLocation!='4') {
                  message.warn('请选择')
                  return false
              }else{
                  hrefModalObj.busiName = "",
                  hrefModalObj.linkUrl = ''
                  hrefModalObj.jumpUrl= 'pages/biz/index/index'
              }
             
              if(selectedRows[0]){  
                  let obj = {...cloneDeep(hrefModalObj),  ...cloneDeep(selectedRows[0])}
                  hrefInfo = getHref(obj )
              }else{
                  let obj={
                  ...cloneDeep(hrefModalObj),
                  contentId:hrefModalObj.params&&hrefModalObj.params.contentId,
                  productId:hrefModalObj.params&&hrefModalObj.params.productId
                  }
                  hrefInfo = getHref(obj)
              }
              currentItem = selectedRowKeys
          }
            hrefModalObj = {...hrefModalObj, ...hrefInfo}
            Object.keys(biz).map((item,idx)=>{
                if(hrefModalObj.jumpLocation!=item){
                    biz[item].selectedRowKeys=[]
                }
            })
            changeState({hrefModalObj,currentItem,biz})
        }
          
        let pageProps = {
            '1': {   //楼盘
              // ---------- 界面部分 ----------
              ui: {
                // 页面接口地址
                api_url: 'admin/estate/adminList',
                // 接口方式
                method: 'POST',
                headers: {
                  'Content-type': 'application/json'
                },
                app: '',
                // 接口参数
                params: 'pageNo=1&pageSize=10&shelfStatus=1',
                // 模拟数据 - 用于开发需要，若填充了上面的api_url之后，请将此项设置为null
                // "mockData": mockData,
                mockData: null,
                // 查询栏
                search_bar: {
                  fields: [
                    {
                      en_name: 'province',
                      zh_name: '城市',
                      elem_type: 'Cascader',
                      elem_valid_type: 'string',
                      changeOnSelect: true,
                      cmpt_items: areaList1,
                      split_keys: ['province', 'city'],
                    },
                    {
                      en_name: 'name',
                      zh_name: '项目名称',
                      elem_type: 'Input',
                      elem_valid_type: 'string',
                    },
                    // {
                    //   en_name: 'shelfStatus',
                    //   zh_name: '状态',
                    //   elem_type: 'Select',
                    //   cmpt_items: [
                    //     {value: null, label: '全部'},
                    //     {value: '0', label: '未上架'},
                    //     {value: '1', label: '已上架'},
                    //     {value: '2', label: '已下架'},
                    //   ],
                    //   elem_valid_type: 'string',
                    // },
                  ],
                  searchHandler: (e) => { // 自定义搜索按钮回调函数，点击搜索时触发
                    console.log('search click', e)
                  },
                  resetHandler: () => { // 自定义重置按钮回调函数，点击重置时触发
                    console.log('reset click')
                  },
                  searchCallback: params => { // 自定义搜索完成后的后调函数, 搜索完成后触发, 并将本次搜索的参数传入
                    console.log('search finish', params)
                  },
                  pasteTargetList: [  // 列表组件中将输入框的en_name作为默认id(也可以通过id另外设置)
                    'carName',  // 将需要粘贴事件拦截的输入框id以数组的形式传入, 该参数对应PasteFromClipboard组件的targetList参数
                  ]
                },
                // 数据表格
                'table':
                  {
                    rowSelectionInfo: {
                      type: 'radio',
                    },
                    key: 'productId',
                    status_params: 'status=0',
                    status_text: '全部',
                    // 表头字段列表
                    scroll: {x: 800},
                    fields: [
                      {
                        en_name: 'estateCode',
                        zh_name: '项目编号',
                        // width: 150,
                      },
                      {
                        en_name: 'name',
                        zh_name: '项目名称',
                        // width: 100,
                      },
                      {
                        en_name: 'cityName',
                        zh_name: '所属城市',
                        width:150,
                        // width: 100,
                        render: (a, item, index, d, e, f) => {
                          let arr = ['北京市', '重庆', '上海', '天津']
                          if (arr.indexOf(item.provinceName) > -1) {
                            return item.cityName
                          } else {
                            return `${item.provinceName||''}${item.provinceName&&item.cityName&&' - '||''}${item.cityName||''}`
                          }
                          
                        }
                      },
                      {
                        en_name: 'shelfStatus',
                        zh_name: '状态',
                        width: 80,
                        render: (a, item, index, d, e, f) => {
                          let shelfStatus = ['未上架', '已上架', '已下架']
                          return (
                            <span>{shelfStatus[item.shelfStatus]}</span>
                          )
                        }
                      },
                      {
                        en_name: 'createPerson',
                        zh_name: '创建人',
                        // width: 100,
                      },
                      {
                        en_name: 'createTime',
                        zh_name: '创建时间',
                        width: 180
                      },
                    ],
                    // 表格操作
                    actions: [],
                  },
                action_bar: [
                  {
                    // label:'',
                    // type:'',
                    rowSelection: [],
                    render: () => {
                      return <Input hidden/>
                    },
                    onClick: (e, row) => {
                    }
                  },
                ]
              },
            },
            '2': {   //专题活动
              // ---------- 界面部分 ----------
              ui: {
                // 页面接口地址
                // api_url: "",
                api_url: 'admin/seckillActivity/advertList',
                method: 'POST',
                headers: {
                  'Content-type': 'application/json'
                },
                app: '',
                // 接口参数
                params: 'published=2',
                // 模拟数据 - 用于开发需要，若填充了上面的api_url之后，请将此项设置为null
                // "mockData": mockData,
                mockData: null,
                search_bar: {
                  fields: [
                    {
                      en_name: 'province',
                      zh_name: '省市',
                      elem_type: 'Cascader',
                      elem_valid_type: 'string',
                      cmpt_items: areaList1,
                      split_keys: ['province', 'city'],
                      //关联的更改的搜索字段
                      related_key: 'businessId',
                      //请求地址
                      related_req_url: 'admin/estate/adminList',
                      //默认请求
                      related_req_param: {
                        pageNo: 1,
                        pageSize: 1000
                      }
                    },
                    {
                      en_name: 'businessId',
                      zh_name: '项目名称',
                      elem_type: 'Select',
                      elem_valid_type: 'string',
                      cmpt_items: []
                    },
                    {
                      en_name: 'sellType',
                      zh_name: '活动类型',
                      elem_type: 'Select',
                      elem_valid_type: 'string',
                      cmpt_items: [{value:1,label:'秒杀'},{value:2,label:'竞拍'}]
                    },
                    // {
                    //   en_name: 'title',
                    //   zh_name: '资讯标题',
                    //   elem_type: 'Input',
                    //   elem_valid_type: 'string',
                    // }
    
                  ],
                  pasteTargetList: [  // 列表组件中将输入框的en_name作为默认id(也可以通过id另外设置)
                    'channel',  // 将需要粘贴事件拦截的输入框id以数组的形式传入, 该参数对应PasteFromClipboard组件的targetList参数
                  ]
                },
                // 数据表格
                'table':
                  {
                    rowSelectionInfo: {
                      type: 'radio',
                    },
                    key: 'seckillActivityId',
                    status_params: 'status=0',
                    status_text: '全部',
                    // 表头字段列表
                    scroll: {x: 800},
                    fields: [
                      {
                        en_name: 'name',
                        zh_name: '活动名称',
                      },
                      {
                        en_name: 'type',
                        zh_name: '活动类型',
                        render:(text)=>{
                          return (
                            <span>{['','秒杀','竞拍'][text]}</span> 
                          )
                        }
                      },
                      {
                        en_name: 'productNames',
                        zh_name: '所属项目',
                      },
                      {
                        en_name: 'productCitys',
                        zh_name: '所属城市',
                      },
                    ],
                    // 表格操作
                    actions: [],
                    pagination: {
                      
                    },
                  },
                action_bar: [
                  {
                    // label:'',
                    // type:'',
                    rowSelection: [],
                    render: () => {
                      return <Input hidden/>
                    },
                    onClick: (e, row) => {
                      console.log(e, row)
                    }
                  },
                ]
              },
            },
          };

            // hrefType 链接类型//(1:推介 2：内部链接 3：资讯 4:外部链接 5：活动，6：预约看房，7：美房详情)
        (['1', '2']).map((item, index) => {
          let _biz = biz[item + '']
          if (!!_biz) {
            pageProps[item + ''].biz = _biz
            pageProps[item + ''].biz.syncBackCbf = (newbiz) => {
              if(item==hrefModalObj.jumpLocation){
                newbiz.selectedRowKeys=currentItem
              }
              biz[item + ''] = newbiz
              dispatch({
                type: `${namespace}/updateStore`,
                payload: {biz}
              })
            }
          }
        })

    
    //提交
    function submit(type) {
        validateFields((err, values) => {
            if (!err) {
                dispatch({
                    type: `${namespace}/submit`,
                    payload: {opsType:type=='保存'?'1':'2'}
                })
            }
        });
        // if(type=='预览'){
        //    dispatch({
        //             type:`${namespace}/updateStore`,
        //             payload:{scan:true}
        //           })
        // }
    }
    //输入框改变时
    function inputChange(e, name) {
      if(name=='regionId'){
        if(e==0){
          show=false
          e=''
        }else{
          show=true
        }
        setFieldsValue({
          productId:null
        })
        regions.map((item)=>{
          if(item.value==e){
            console.log(item.label,item.productIdAll)
            query2.regionName=item.label
            products=item.products
            query2.productId=''
            showAll=item.productIdAll
          }
        })
      }else if(name=='productId'){
        products.map((item)=>{
          if(item.value==e){
            productName=item.label
            console.log(hrefModalObj.busiName)
            if(hrefModalObj.busiName=='undefined'){
              hrefModalObj.busiName=item.label
            }
          }
        })
        if(e!=0){
          hrefModalObj.jumpLocation=1
          currentItem[0]=e
          location=1
        }
      }else if(name=='channelName'){
        if(!!e){
          dispatch({
            type: `${namespace}/getKeys`,
            payload:{channelName:e}
          })
        } 
        
      }
        dispatch({
            type: `${namespace}/updateStore`,
            payload: {
              query2: {
                    ...query2,
                    [name]: e,
                },
                products,
                productName,
                showUl,
                hrefModalObj,
                show,
                location,
                showAll
            }
        })
    }
    return (
        <div className={cx('pageLayout')}>
            <div className='public_listMain'>
                <div className={"functionButton"}>
                {query1.actionType=='detail'?null:<Button type='primary' onClick={e => submit('保存')} loading={modelObj.btnLoading}>保存</Button>}
                </div>
                   
                        <CollapsiblePanels >
                        {/* title="广告弹窗信息" hideUpDownBtn={true} sTitle={actionType == 'detail'?`状态：${['','生效中','未生效','已失效'][query.status]}`:''} */}
                        <Row>
                          
                            <Col span={8}>
                                <FormItem label='区域'  {...formItemLayoutPro}>
                                    {getFieldDecorator('regionId', {
                                        rules: [{required:true,
                                          whitespace: true, message: '请选择区域'
                                        }],
                                        initialValue: query2.regionId?query2.regionId +'':undefined
                                    })(
                                        <Select onChange={e=>{inputChange(e,'regionId')}} disabled={query1.actionType=='detail'}>
                                          {roleType==1?
                                            <Select.Option value='0' key='0' >全部</Select.Option>:null
                                          }
                                          
                                            {
                                                regions.map((item,index)=>{
                                                    return <Select.Option value={item.value} key={index}>{item.label}</Select.Option>
                                                })
                                            }
                                            
                                        </Select>
                                    )}
                                </FormItem>
                            </Col>
                            {show?
                            <Col span={8}>
                                <FormItem label='所属项目'  {...formItemLayoutPro}>
                                    {getFieldDecorator('productId', {
                                        rules: [{required:true,
                                            message: '请选择所属项目'
                                        }],
                                        initialValue: query2.productName?query2.productName:undefined
                                    })(
                                        <Select onChange={e=>{inputChange(e,'productId')}} disabled={query1.actionType=='detail'}>
                                            {roleType==3 || !showAll?null:<Select.Option value='0' key='0'>全部</Select.Option>}
                                            {
                                                products.map((item,index)=>{
                                                    return <Select.Option value={item.value} key={index} >{item.label}</Select.Option>
                                                })
                                            }
                                        </Select>
                                    )}
                                </FormItem>
                            </Col>
                                :null}
                            
                        </Row>  
                        <Row> 
                            <Col span={8}>
                                <FormItem label='传播渠道1类'  {...formItemLayoutPro}>
                                    {getFieldDecorator('channelType', {
                                        rules: [{required:true, message: '请选择传播渠道1类'
                                          } ],
                                          initialValue: query2.channelType ? query2.channelType: undefined
                                    })(
                                      <Select onChange={e=>{inputChange(e,'channelType')}} disabled={query1.actionType=='detail'}>
                                          {
                                              types.map((item)=>{
                                                return <Select.Option value={item.id}>{item.name}</Select.Option>
                                            })
                                          }
                                      </Select>
                                    )}
                                </FormItem>
                            </Col>
                        </Row>
                        <Row> 
                            <Col span={8}>
                                <FormItem label='传播渠道2类'  {...formItemLayoutPro}>
                                    {getFieldDecorator('channelName', {
                                        rules: [{
                                            required:true,message: '请输入传播渠道2类'
                                          
                                          } ],
                                          initialValue: query2.channelName?query2.channelName +'' : undefined
                                    })(
                                      <div className={styles.ul} >
                                        <Input onChange={e=>{inputChange(e.target.value,'channelName')}} onFocus={()=>{
                                          dispatch({
                                            type: `${namespace}/updateStore`,
                                            payload:{
                                              showUl:true
                                            }
                                            
                                            })
                                          
                                        }}
                                         onBlur={()=>{
                                          console.log('失去焦点')
                                          dispatch({
                                            type: `${namespace}/updateStore`,
                                            payload:{
                                              showUl:false
                                              }
                                            })
                                        }} 
                                        disabled={query1.actionType=='detail'} value={query2.channelName}></Input>
                                        {showUl&&list.length>0?<ul>
                                          {list.map((item,index)=>{
                                            return <li onMouseDown={()=>{
                                              console.log('fas')
                                              dispatch({
                                                type:`${namespace}/updateStore`,
                                                payload:{
                                                  query2:{
                                                    ...query2,
                                                    channelName:item, 
                                                  },
                                                  showUl:false
                                                }
                                              })
                                            }}>{item}</li>
                                          })}
                                        </ul>:null}
                                      </div>
                                    )}
                                </FormItem>
                                
                            </Col>
                            <Col className={styles.tips} span={12}>
                            <span>说明：传播渠道名称要唯一，支持关键字搜索。如：天河城框架、快闪活动、现场物料</span>
                            </Col>
                            
                        </Row>
                        
                          <Row>
                            <Col span={8}>
                                <FormItem label='二维码跳转到' required='true' {...formItemLayoutPro}>
                                {getFieldDecorator('jumpLocation', {
                                rules:[{
                                       
                                        } 
                                    ],
                                    })(
                                        <Col span={6}>
                                            <Button onClick={() => {updateModal(true)}} disabled={query1.actionType=='detail'}>
                                                更换跳转
                                            </Button>
                                        </Col>
                                    )}
                                       
                                </FormItem>
                            </Col>
                            {hrefModalObj.busiName || productName ||query2.busiName || query1.actionType=='detail'?<Col span={6} >
                                <FormItem>
                                  {location==1?<span><span style={{fontSize:12,marginLeft:'15px'}}> 当前跳转项目: </span> {query1.actionType=='detail'?query2.busiName || query2.productName:hrefModalObj.busiName || productName }</span>:null}
                                  {(hrefModalObj.jumpLocation=='2' || query2.jumpLocation=='2')?<span><span style={{fontSize:12,marginLeft:'15px'}}> 当前跳转活动: </span> 
                                  {hrefModalObj.busiName}
                                  </span>:null}
                                </FormItem>
                            </Col>:null}
                            {hrefModalObj.jumpLocation?<Col span={4}>
                                <FormItem >
                                  <span ><span style={{fontSize:12}}>跳转类型:</span> 
                                  {/* {query1.actionType!='detail'?objhref[hrefModalObj.jumpLocation]:hrefModalObj.channelTypeName} */}
                                  {objhref[location]}
                                  </span>
                                </FormItem>
                            </Col>:null}
                            </Row>  
                        <Row> 
                            
                            
                            
                         
                        {hrefModalObj.jumpUrl || query2.productId ||query2.busiId?<Col span={16}>
                        
                          <FormItem label='跳转Url'  {...formItemLayout2}>
                                {getFieldDecorator('url', {
                                rules:[{
                                       
                                        } 
                                    ],
                                    })(
                                        <Col >
                                             {
                              query1.actionType=='detail'?(query2.jumpLocation=='1'?`pages/biz/buildingDetail/buildingDetail?productId=${query2.busiId || query2.productId}`:query2.jumpUrl):hrefModalObj.jumpUrl ||`pages/biz/buildingDetail/buildingDetail?productId=${query2.productId}`
                            }
                                        </Col>
                                    )}
                                       
                                </FormItem>
                            {/* <span className={styles.href}><span style={{fontSize:12,marginLeft:'44px'}}>跳转Url: </span> 
                            {query1.actionType=='detail'?`pages/biz/buildingDetail/buildingDetail?productId=${query2.busiId}`:}
                            {
                              query1.actionType=='detail'?(query2.jumpLocation=='1'?`pages/biz/buildingDetail/buildingDetail?productId=${query2.busiId || query2.productId}`:query2.jumpUrl):hrefModalObj.jumpUrl ||`pages/biz/buildingDetail/buildingDetail?productId=${query2.productId}`
                            }
                            </span> */}
                          </Col>
                        :null}
                        </Row>
                        <Row>
                            <Col span={16}>
                                <FormItem {...formItemLayout2} label='备注'>
                                    {getFieldDecorator('remark',{
                                        rules:[{}],
                                        initialValue: query2.remark ? query2.remark +'' : undefined
                                    })(
                                        <TextArea onChange={e=>{inputChange(e.target.value,'remark')}} disabled={query1.actionType=='detail'}></TextArea>
                                    )}
                                </FormItem>
                            </Col>
                        </Row>
                        <Row>                         
                            <Button className={styles.btn} onClick={()=>{
                              submit('预览')
                              // dispatch({
                              //   type:`${namespace}/updateStore`,
                              //   payload:{scan:true}
                              // })
                            }} disabled={query1.actionType=='detail'}>预览</Button>
                            <span style={{'marginLeft':'20px'}}> 设置好跳转页面后点击按钮可预览二维码</span>
                        </Row>
                        {scan&&query2.imgUrl!=''?
                        <Row>                         
                            <img style={{'width':'300px','height':'300px','marginTop':'20px','marginLeft':'100px'}} src={query2.imgUrl}></img>
                        </Row>:null
                        }
                        

                        
                       
                        </CollapsiblePanels>
            </div>
             {/*链接弹窗*/}
      <Modal
        visible={hrefModalObj.visible}
        onOk={confirmHref}
        onCancel={() => {
          updateModal(false)
        }}
        width={'80%'}
      >
        <div style={{padding: '10px'}} className={styles.sty}>
          <div className={'mgb1'}>广告链接</div>
          <Form>
            <Tabs onChange={changeTab_modal} type="line" activeKey={hrefModalObj.jumpLocation + ''}>
              <TabPane tab=" 楼盘主页" key="1"></TabPane>
              <TabPane tab=" 秒杀竞拍" key="2"></TabPane>
              <TabPane tab=" 外部链接" key="3"></TabPane>
              <TabPane tab=" 美的置业云小程序首页" key="4"></TabPane>
              <TabPane tab=" 自定义" key="5"></TabPane>

            </Tabs>
            {/*首页 1*/}
           
            {/*楼盘 2*/}
            {
              <div title="楼盘" className={cx(hrefModalObj.jumpLocation == '1' ? '' : 'hidden')}>
                <ListPage pageProps={pageProps['1']}/>
              </div>
            }
            
            {/*秒杀竞拍 3*/}
            {
              <div title="秒杀竞拍" className={cx(hrefModalObj.jumpLocation == '2' ? '' : 'hidden')}>
                <ListPage pageProps={pageProps['2']}/>
              </div>
            }
            
            
            
            {/*外部链接 4*/}
            {
              <div className={cx(hrefModalObj.jumpLocation == '3' ? '' : 'hidden')}>
                    <FormItem {...formItemLayout1} label="跳转链接" >
                      {getFieldDecorator('new_href', {
                        initialValue: location==3?hrefModalObj.jumpUrl :' ',
                        // rules: [
                        //   { required: true, whitespace: true, message: `请输入正确链接`, pattern: /(http|ftp|https):\/\/([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?/ },
                        // ],
                      })(
                        <Input
                        placeholder={'请输入链接'}
                        onChange={(e) => {
                          hrefModalObj.jumpUrl = e.target.value
                          changeState({hrefModalObj})
                        }}
                      />
                      )}
                    </FormItem>
                    <div style={{marginLeft:'8%',color:'#999',marginTop:'-5px'}}>请先与集团IT-谭嘉杰(tanjj9@midea.com)，经集团备案转换后再录入</div>
                  
                
               </div> 
              
            }
             {
              <div className={cx(hrefModalObj.jumpLocation == '4' ? '' : 'hidden')}>
                <FormItem {...formItemLayout} label="" hasFeedback>
                  <span>跳转到美的置业云小程序首页</span>
                </FormItem>
              </div>
            }
            {
              <div className={cx(hrefModalObj.jumpLocation == '5' ? '' : 'hidden')}>
                <div>跳转到自定义的富文本，可以上传海报，图文等。用户需要注册和登录才能访问查看。</div>
                <div>备注：不能在本页面配置外部H5网址，跳转过去外部H5网址</div>
                <Row>
                  <Col span={12}>
                      <FormItem label='页面标题'  {...formItemLayout2}>
                        {getFieldDecorator('title', {
                          rules: [{
                            required: false, message: '仅限制8个字', max: 8
                          }],
                          initialValue: query2.title,
                        })(
                          <Input placeholder="仅限制8个字" onChange={(e) => { inputChange(e.target.value, 'title') }} />
                        )}
                      </FormItem>
                  </Col>
                </Row>
                <Row>
                <Col className="col" span={24} >
                  <FormItem
                    // {...formItemLayout}
                    {...{ labelCol: { span: 2 }, wrapperCol: { span: 22 } }}
                    label='图文编辑'>
                    {(
                      <div>
                        <Ueditor  id="infoDetail"
                            editable={actionType === 'detail'?false:true} 
                            html={query2.content||''}
                            title={query2.title||''}
                            startDate={query2.startDate||''}
                            endDate={query2.endDate||''}
                            height={500}
                            // enableBtn={isSubmit}
                            inputChange={e => {
                                  dispatch({ type: `${namespace}/dealEditor`, payload: { detail: e } })
                                }}
                            // isSubmit={
                            //   e=>{dispatch({ type: `${namespace}/updateStore`, payload: { isSubmit:e.isSubmit } })}
                            // }
                          />
                      </div>
                    )}
                  </FormItem>
                </Col>
              </Row>
              </div>
            }
            
          
          </Form>
        </div>
      </Modal>
     
        </div>

    )
}
// 连接视图(view)和模型(model)
export default connect(mapStateToProps)(Form.create()(advertisingWindowDetailView))
